package com.mqz.rocketmq.consumer.component;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.annotation.SelectorType;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * 版权所有  copyright© 蒙大拿
 *
 * @author mqz
 * @date 2022/7/28
 * @about https://www.gitee.com/DemoMeng
 * @description
 */
@Component
@RocketMQMessageListener(consumerGroup = "mengqizhang-sql-group",
        topic = "mengqizhang-sql-topic",
        messageModel = MessageModel.BROADCASTING,
        selectorExpression = "name= 'mengqizhang' AND address = 'hangzhou' ",
        selectorType = SelectorType.SQL92)
@Slf4j
public class ConsumerFilterSQL implements RocketMQListener<MessageExt> {
    @Override
    public void onMessage(MessageExt message) {
        String tag = message.getTags();
        String msg = new String(message.getBody());
        log.info("sql filter : {},msg :{} ",tag,msg);
    }
}
